<?php
namespace app\index\controller;
use think\Controller;
use app\index\Lib\Weixin;
class Base extends Controller {
   private static $code;
   public function __construct(){
      parent::__construct();
      if (empty(session("user"))){
          self::$code = request()->get("code");
          if (empty(self::$code)){
              $this->error("身份信息有误，请先登录！");
          }
          $weixin = new Weixin();
          $userinfo = $weixin->getUserInfo(self::$code);
          $user_ticket= $userinfo['user_ticket'];
          $userDetail = $weixin->getUserDetail($user_ticket);
          session("user",$userDetail);
      }
   }
}